const arr = [
    {name: 'zhang san'},
    {name: 'li san'},
    {name: 'wang san'},
    {name: 'zeng san'},
    {name: 'ling san'},
    {name: 'zhaoliu san'},
];
function group(arr){
    //声明一个数组
    let container = {};
    //遍历数组
    arr.forEach(item => {
        //获取首字母
        let letter = item.name.substr(0,1);
        //检测 container 中是否包含
        if(!container.hasOwnProperty(letter)){
            container[letter] = [item];
        }else{
            container[letter].push(item);
        }
    });
    //遍历container
    return Object.values(container);
}
console.log(group(arr));